import tkinter as tk
import time
class Clock(tk.Tk):
    def __init__(self) -> None:
        super().__init__()
        self.attributes("-topmost",True)
        self.attributes("-alpha",0.9)
        self.overrideredirect(True)
        self.geometry("200x110")
        self.configure(borderwidth=5,relief="raised")

        self.label_time = tk.Label(self,font=("Helvetica",32,"bold"),bg = "black",fg = "green")
        self.label_time.pack(expand=1)

        # 创建自定义标签
        self.saving_label = tk.Label(self,text="珍惜精力,合理分配",font=("Helvetica",16,"bold"))
        self.saving_label.place(relx=1.0,rely=1.0,anchor = tk.SE)
        self.update_clock()

        self.bind("<Button-1>",self.start_move)
        self.bind("<B1-Motion>",self.on_move)

    def start_move(self, event):
        self._x = event.x
        self._y = event.y
    
    def on_move(self, event):
        deltax = event.x - self._x
        deltay = event.y - self._y

        x = self.winfo_x() + deltax
        y = self.winfo_y() + deltay

        self.geometry(f"+{x}+{y}")
    def update_clock(self):
        current_time = time.strftime("%H:%M:%S")
        self.label_time.config(text=current_time)
        self.after(1000,self.update_clock)

if __name__ == "__main__":
    Clock().mainloop()